<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>居民区项目信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="javascript">

$(document).ready(function(){
	$('#partyKey').val('${communityProject.communityGeneralParty.timeKey}');
});

function goback(){
	var editFrom = ${editFrom };
	var timeKey = $('#timeKey').val();
	if(editFrom == 1){
		window.location.href="/djzx/CommunityProjectAction!getProjectListForPage.action";
	}else if(editFrom == 2){
		window.location.href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=" + timeKey;
	}else{
		
	}
}

function updateProject(){
	var timeKey = $.trim($('#timeKey').val());
	var name = $.trim($('#name').val());
	var content = $.trim($('#content').val());
	var attendNum = $.trim($('#attendNum').val());
	var partyKey = $.trim($('#partyKey').val());
	var workMemberNum = $.trim($('#workMemberNum').val());
	var date  = $.trim($('#date').val());
	
	if(name==""){
		alert("项目名称不能为空");
		return;
	}
	if(content==""){
		alert("项目内容不能为空");
		return;
	}
	if(attendNum==""){
		alert("参加人数不能为空");
		return;
	}else if(isNaN(attendNum)){
		alert("参加人数必须为数字");
		return;
	}
	if(partyKey==""){
		alert("党组织名称不能为空");
		return;
	}
	if(workMemberNum==""){
		alert("在职党员人数不能为空");
		return;
	}else if(isNaN(workMemberNum)){
		alert("在职党员人数必须为数字");
		return;
	}
	if(date==""){
		alert("日期不能为空");
		return;
	}
	
	attendNum = parseInt(attendNum);
	var fd = new FormData();
	fd.append('communityProject.timeKey',timeKey);
	fd.append('communityProject.name',name);
	fd.append('communityProject.content',content);
	fd.append('communityProject.attendNum',attendNum);
	fd.append('communityProject.communityGeneralParty.timeKey',partyKey);
	fd.append('communityProject.workMemberNum',workMemberNum);
	fd.append('communityProject.date',date);
	
	$.ajax({
	    url:"${pageContext.request.contextPath}/CommunityProjectAction!updateProject.action",
	    type:"POST",
	    data:fd,
	    dataType: "json", 
	    contentType: false, //必须
	    processData: false, //必须
	    success:function(data){
	    	alert(data.message);
			if(data.success){
				var editFrom = ${editFrom };
				var timeKey = $('#timeKey').val();
				if(editFrom == 1){
					window.location.href="/djzx/CommunityProjectAction!getProjectListForPage.action";
				}else if(editFrom == 2){
					window.location.href="/djzx/CommunityProjectAction!toShowProject.action?communityProject.timeKey=" + timeKey;
				}else{
					
				}
			}
	    }
	}); 
}

</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">编辑项目</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<input type="hidden" name="timeKey" id="timeKey" value="${communityProject.timeKey }" />
<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="120" height="24" class="td_form01">项目名称</td>
        <td nowrap class=td_form02>
        	<input type="text" name="name" id="name" size="30" value="${communityProject.name }" />
        </td>
        <td width="120" class="td_form01">项目内容</td>
        <td nowrap class=td_form02>
        	<input type="text" name="content" id="content" size="30" value="${communityProject.content }" />
        </td>
      </tr>
      <tr>
        <td class="td_form01">参加人数</td>
        <td nowrap class=td_form02>
        	<input type="text" name="attendNum" id="attendNum" size="30" value="${communityProject.attendNum }" />
        </td>
        <td class="td_form01">党组织名称</td>
        <td nowrap class=td_form02>
        	<select name="partyKey" id="partyKey">
        	  <s:iterator value="communityGeneralPartyList" var="c" status="statu">
        	  	<option value="${c.timeKey }">${c.name }</option>
        	  </s:iterator>
      		</select>
        </td>
      </tr>
      <tr>
        <td class="td_form01">在职党员人数</td>
        <td nowrap class=td_form02>
        	<input type="text" name="workMemberNum" id="workMemberNum" size="30" value="${communityProject.workMemberNum }" />
        </td>
        <td class="td_form01">日期</td>
        <td nowrap class=td_form02>
        	<input type="text" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="date" id="date" value="${communityProject.date }" readonly="readonly" />
			<img alt="" src="/djzx/images/datePicker.png">
        </td>
      </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><input name="Submit2" type="submit" class="buttonface" value="  保存  " onClick="updateProject()">
    <input name="Submit" type="submit" class="buttonface" value="  返回  "  onClick="goback()"></td>
  </tr>
</table>
<br>
</body>
</html>